#ifndef Lcd_H
#define Lcd_H

#include "stdint.h"
#include "mytype.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define TEXT_X_LEFT 0x00		
#define TEXT_X_MID 0x01			
#define TEXT_X_RIGHT 0x02		
#define TEXT_Y_UP (0x00 << 2)	
#define TEXT_Y_MID (0x01 << 2)	
#define TEXT_Y_DOWN (0x02 << 2) 

#define TEXT_MID (TEXT_X_MID | TEXT_Y_MID)
#define TEXT_LEFT_DOWN (TEXT_X_LEFT | TEXT_Y_DOWN)
#define TEXT_LEFT_UP (TEXT_X_LEFT | TEXT_Y_UP)
#define TEXT_RIGHT_DOWN (TEXT_X_RIGHT | TEXT_Y_DOWN)
#define TEXT_RIGHT_UP (TEXT_X_RIGHT | TEXT_Y_UP)

#define TEXT_SQ_W(n) ((n) << 4)	 
#define TEXT_SQ_PX(n) ((n) << 6) 
#define TEXT_SQ_PY(n) ((n) << 9) 
#define TEXT_SQ(w, px, py) (TEXT_SQ_W(w) | TEXT_SQ_PX(px) | TEXT_SQ_PY(py))

#define TEXT_LINE_N(n) ((n) << 12)	   
#define TEXT_LINE_W(n) ((n - 1) << 14) 
#define TEXT_LINE(w, n) (TEXT_LINE_W(w) | TEXT_LINE_N(n))

	extern const unsigned char Font_6_12[];
	extern const unsigned char Font_8_16[];
	extern const unsigned char Font_12_24[];
	extern const unsigned char Font_16_32[];
	extern const unsigned char Font_24_48[];
	extern const unsigned char Font_32_64[];
	extern const unsigned char Font_48_96[];
	extern const unsigned char Font_64_128[];

	extern const ii16 lcd_yl_size_x;   
	extern const ii8 lcd_yl_page_size; 
	extern const ii16 lcd_yl_size_y;   
	extern const ii8 lcd_yl_block_num; 

	void lcd_yl_init(void);
	void lcd_yl_disp_buff_set(uu8 *pbuff);						  
	void lcd_yl_font_set(uu8 Fontx, uu8 Fonty, const uu8 *Ascii); 
	void lcd_yl_half_en(void);									  
	void lcd_yl_half_dis(void);									  
	void lcd_yl_anti(void);										  
	void lcd_yl_normal(void);									  
	void lcd_yl_space_set(uu8 Space);							  
	void lcd_yl_origin_set(ii16 x0, ii16 y0);					  

	void lcd_yl_put_space(ii16 x, ii16 y, ii8 Amounts);				 
	void lcd_yl_put_char(ii16 x, ii16 y, char DispCh);				 
	void lcd_yl_put_cn(ii16 x, ii16 y, const uu8 *pCN);				 
	void lcd_yl_puts(ii16 x, ii16 y, const char *DispStr);			 
	void lcd_yl_put_nums(ii16 x, ii16 y, const char *DispStr);		 
	void lcd_yl_put_cns(ii16 x, ii16 y, ii8 Amount, const uu8 *pCN); 
	void lcd_yl_ram_set(ii16 x, ii8 Page, uu8 Data);				 
	uu8 lcd_yl_ram_read(ii16 x, ii16 Page);							 
	void lcd_yl_dot_set(ii16 x, ii16 y);							 
	void lcd_yl_dot_clr(ii16 x, ii16 y);							 
	void lcd_yl_ram_fill(uu8 Val);									 
	void lcd_yl_line(ii16 x0, ii16 y0, ii16 x1, ii16 y1);			 
	void lcd_yl_square(ii16 x0, ii16 y0, ii16 x1, ii16 y1);			 
	void lcd_yl_square_fill(ii16 x0, ii16 y0, ii16 x1, ii16 y1);	 
	void lcd_yl_imgage(ii16 x, ii16 y, ii16 wide, ii16 high, unsigned char const *pImg);
	void lcd_yl_circle(ii16 x, ii16 y, ii16 r);

	void lcd_yl_alain_puts(ii16 x, ii16 y, const char *DispStr, uu16 mode);					   
	void lcd_yl_alain_put_nums(ii16 x, ii16 y, const char *DispStr, uu16 mode);				   
	void lcd_yl_alain_put_cns(ii16 x, ii16 y, ii8 Amount, const uu8 *pCN, uu16 mode);		   
	dword_tt lcd_yl_alain_xy_get(ii16 x, ii16 y, const char *DispStr, ii16 cn_num, uu16 mode); 
	void lcd_yl_alain_sq_and_line(ii16 x, ii16 y, ii16 text_wide, uu16 mode);

	void lcd_yl_alain_ext_puts(ii16 x, ii16 y, const char *str, uu16 mode);
	extern const uu8 *lcd_yl_gb2312_cn_get(uu32 mem_offset, uu16 font_x); 

	void lcd_yl_poll(uu16 x0, uu8 disp_page0, uu8 page_amount); 
	void lcd_yl_poll_ext(uu16 x0, uu16 y0, uu8 page_amount);	
	uu8 lcd_yl_update_cnt_get(void);

	void lcd_hal_init(void);
	
	void lcd_data_write(char page, uu8 *pdata);
	void lcd_data_write_ext(char page, uu8 *pLineUp, uu8 *pLineDn, uu8 offset);

#ifdef __cplusplus
}
#endif

#endif 
